function [tm_scale, sp_scale] = lrscales(sc_type, alpha, refvar, ...
                                         acc, maxtime, b_verb)

% LRSCALES Compute the time and space scales according to the
% limiting regimes for aggregated processes of counting type. Three
% regimes are known, see SCALEREN, SCALEMGINFTY, SCALEONOFF.
%
% The "acceleration factor", i.e. the ratio between two adjacent time
% scales, should be chosen as large as possible but not too large to
% be able to observe a sufficient number of events in the common time
% window. See LRACC.
%
% [tm_scale, sp_scale] = lrscales(sc_type, alpha, refvar, ...
%                                 acc, maxtime, b_verb)
% 
% Inputs:
%        sc_type - type of scaling: 1-fBm, 2-Intermediate, 3-Levy
%          motion, can be a vector containing combinations of the
%          above 
%        alpha - tail parameter of the sojourn distribution:
%          normalized Pareto, 1<alpha<=2
%        refvar - reference variable; number of processes
%          superposed in the models of superposition of renewal
%          processes and integrated sum of on-off processes,
%          arrival intensity in the infinite source Poisson model.
%        acc - acceleration factor
%        maxtime - time window of the process before rescaling
%        b_verb - if 1 then print processing info
%
% Outputs:
%        tm_scale - a column vector of the time scales
%          corresponding to the regimes given in sc_type
%        sp_scale - a column vector of the space scales
%          corresponding to the regimes given in sc_type

% Authors: R.Gaigalas, I.Kaj
% v1.2 17-Dec-05


  nout = length(sc_type);
  tm_scale = zeros(nout, 1);
  sp_scale = zeros(nout, 1);
  
  % the time scale in the Intermediate regime is our reference  
  icr_scale = refvar^(1/(alpha-1));  
  
  % Fast-fBm regime
  % number of users grows faster than the time scale
  tp1i = find(sc_type == 1);
  tm_scale(tp1i) = icr_scale/acc; % slow down time
  sp_scale(tp1i) = (refvar*tm_scale(tp1i).^(3-alpha)).^0.5;
      
  % Intermediate regime
  tp2i = find(sc_type == 2);
  tm_scale(tp2i) = icr_scale;
  sp_scale(tp2i) = icr_scale;
      
  % Slow-Levy motion regime
  % number of users grows slower than the time scale  
  tp3i = find(sc_type == 3);
  tm_scale(tp3i) = icr_scale*acc; % speed up time
  sp_scale(tp3i) = (refvar*tm_scale(tp3i)).^(1/alpha);

  if b_verb % print info
    sc_typemsg = strvcat('Fast-fBm', 'Intermediate', 'Slow-LM');
    for i=1:nout
      fprintf(1, '\n##Rescaling regime %i: %s\n', i, ...
              sc_typemsg(sc_type(i), :));
      fprintf(1, '  time scale: %f\n', tm_scale(i));
      fprintf(1, '  space scale: %f\n', sp_scale(i));
      if (sc_type(i)~= 2)
        fprintf(1, '  acceleration factor: %f\n', acc);
      end	
      fprintf(1, '  time scale/icr scale: %f\n', ...
              tm_scale(i)/icr_scale);
      fprintf(1, '  time scale/space scale: %f\n', ...
              tm_scale(i)/sp_scale(i));
      fprintf(1, '  max time: %f\n', maxtime/tm_scale(i));    
    end
  end
